﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Apewer.Internals
{

    internal static class TextHelper
    {

        public static StringPairs ParseConnectionString(string connectionString)
        {
            var sp = new StringPairs();
            if (string.IsNullOrEmpty(connectionString)) return sp;

            var split = connectionString.Split(";");
            foreach (var item in split)
            {
                var equal = item.IndexOf("=");
                if (equal < 0) continue;
                var left = item.Substring(0, equal).ToTrim();
                var right = item.Substring(equal + 1).ToTrim();
                if (left.IsEmpty() || right.IsEmpty()) continue;
                sp.Add(left, right);
            }
            return sp;
        }

    }

}
